"CDRTool_Session", "auth" => "CDRTool_Auth", "perm" => "CDRTool_Perm")); $title="Provisioning interface"; if (is_readable("local/header.phtml")) { include("local/header.phtml"); } else { include("header.phtml"); } $perm->check("admin"); include("provisioning_lib.phtml"); $layout = new pageLayoutLocal(); $layout->showTopMenu(); $SOAPEngine = new SOAPEngine($_REQUEST['service']); $_class = $SOAPEngine->recordsClass; $RECORDS = new $_class(&$SOAPEngine); if ($_REQUEST['action']=='Add') $RECORDS->addRecord(); if ($_REQUEST['action']=='Delete') $RECORDS->deleteRecord(); $RECORDS->listRecords(); $layout->showFooter(); print " "; class SOAPEngine { var $services=array( 'sipAccounts' => array('recordsClass' => 'SipAccounts', 'soapClass' => 'WebService_NGNPro_SipPort' ), 'sipAliases' => array('recordsClass' => 'SipAliases', 'soapClass' => 'WebService_NGNPro_SipPort' ), 'sipDomains' => array('recordsClass' => 'DomainStatistics', 'soapClass' => 'WebService_NGNPro_SipPort' ), 'enumMappings' => array('recordsClass' => 'EnumMappings', 'soapClass' => 'WebService_NGNPro_EnumPort' ), 'enumRanges' => array('recordsClass' => 'EnumRanges', 'soapClass' => 'WebService_NGNPro_EnumPort' ), 'trustedParties' => array('recordsClass' => 'TrustedPeers', 'soapClass' => 'WebService_NGNPro_SipPort' ), 'pstnGateways' => array('recordsClass' => 'Gateways', 'soapClass' => 'WebService_NGNPro_NetworkPort' ), 'pstnGwGroups' => array('recordsClass' => 'GatewayGroups', 'soapClass' => 'WebService_NGNPro_NetworkPort' ), 'pstnRoutes' => array('recordsClass' => 'Routes', 'soapClass' => 'WebService_NGNPro_NetworkPort' ) ); function SOAPEngine($service) { // $soapEngines must be defined in global.inc global $soapEngines; $this->soapEngines = $soapEngines; if (is_array($this->soapEngines)) { if (!$service) { // Use first defined service in global.inc $_services = array_keys($this->services); $_soapids = array_keys($this->soapEngines); $service = $_soapids[0].":".$_services[0]; } $this->service = $service; $_els=explode(":",$this->service); $this->soapEngineId = $_els[0]; $this->soapEnginePort = $_els[1]; $this->recordsClass = $this->services[$this->soapEnginePort]['recordsClass']; $this->soapClass = $this->services[$this->soapEnginePort]['soapClass']; $this->SOAPlogin = array( "username" => $this->soapEngines[$this->soapEngineId]['username'], "password" => $this->soapEngines[$this->soapEngineId]['password'], "admin" => true ); $this->SOAPurl=$this->soapEngines[$this->soapEngineId]['url']; $this->SoapAuth = array('auth', $this->SOAPlogin , 'urn:AGProjects:NGNPro', 0, ''); // Instantiate the SOAP client $this->soapclient = new $this->soapClass($this->SOAPurl); $this->soapclient->setOpt('curl', CURLOPT_TIMEOUT, 5); $this->soapclient->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); $this->soapclient->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); } else { print "

Error: No SOAP credentials defined."; } } function showEngineSelection() { $selected_soapEngine[$this->service]='selected'; printf (""); } } class Records { var $maxrowsperpage = '20'; function Records(&$SOAPEngine) { $this->SOAPEngine=&$SOAPEngine; $this->filters['sortBy'] = trim($_REQUEST['sortBy']); $this->filters['sortOrder'] = trim($_REQUEST['sortOrder']); $this->next = $_REQUEST['next']; } function showPagination($maxrows) { print "

"; $this->url.="&service=".urlencode($this->SOAPEngine->service); if ($this->next != 0 ) { $show_next=$this->maxrowsperpage-$this->next; if ($show_next < 0) { $mod_show_next = $show_next-2*$show_next; } if (!$mod_show_next) $mod_show_next=0; $url_prev=$_SERVER['PHP_SELF'].$this->url."&next=$mod_show_next"; print "Previous "; } print " "; if ($this->next + $this->maxrowsperpage < $this->rows) { $show_next = $this->maxrowsperpage + $this->next; $url_next = $_SERVER['PHP_SELF'].$this->url."&next=$show_next"; print "Next"; } print "
"; } function showSeachFormCustom() { } function showSeachForm() { print "

"; printf ("",$_SERVER['PHP_SELF']); print "
"; $this->SOAPEngine->showEngineSelection(); $this->showSeachFormCustom(); print " "; $this->showSortForm(); print " "; print "
"; if ($_REQUEST['action'] != 'Delete') $this->showAddForm(); } function listRecords() { } function addRecord() { } function deleteRecord() { } function tel2enum($tel,$tld) { if (strlen($tld) == 0) $tld="e164.arpa"; // transform telephone number in FQDN Enum style domain name if (preg_match("/^[+]?(\d+)$/",$tel,$m)) { $l=strlen($m[1]); $rev_num=""; $z=0; while ($z < $l) { $ss=substr($m[1],$z,1); $enum=$ss.".".$enum; $z++; } preg_match("/^(.*)\.$/",$enum,$m); $enum=$m[1]; $enum=$enum.".$tld."; return($enum); } else { return($tel); } } function showAddForm() { } function showSortForm() { if (!count($this->sortElements)) { return; } $selected_sortBy[$this->filters['sortBy']]='selected'; //print " Sort "; print ""; $selected_sortOrder[$this->filters['sortOrder']]='selected'; print ""; } function showTimezones() { if (!$fp = fopen("timezones", "r")) { print _("Failed to open timezone file."); return false; } print ""; } } class ENUMmappings extends Records { var $sortElements=array('changeDate' => 'Change date', 'number' => 'E.164 number', 'tld' => 'TLD', 'owner' => 'Owner' ); function ENUMmappings(&$SOAPEngine) { $this->filters = array('number' => trim($_REQUEST['number_filter']), 'tld' => trim($_REQUEST['tld_filter']), 'type' => trim($_REQUEST['type_filter']), 'mapto' => trim($_REQUEST['mapto_filter']), 'owner' => trim($_REQUEST['owner_filter']) ); $this->Records(&$SOAPEngine); } function listRecords() { $this->showSeachForm(); // Filter $filter=array('number' => $this->filters['number'], 'type' => $this->filters['type'], 'mapto' => $this->filters['mapto'] ); // Range $range=array('start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->filters['sortBy']) $this->filters['sortBy'] = 'changeDate'; if (!$this->filters['sortOrder']) $this->filters['sortOrder'] = 'DESC'; $orderBy = array('attribute' => $this->filters['sortBy'], 'direction' => $this->filters['sortOrder'] ); // Compose query $Query=array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->url=sprintf("?sortBy=%s&sortOrder=%s",urlencode($this->filters['sortBy']),urlencode($this->filters['sortOrder'])); if (strlen($this->filters['number'])) $this->url .= sprintf("&number_filter=%s",urlencode($this->filters['number'])); if (strlen($this->filters['type'])) $this->url .= sprintf("&type_filter=%s",urlencode($this->filters['type'])); if (strlen($this->filters['mapto'])) $this->url .= sprintf("&mapto_filter=%s",urlencode($this->filters['mapto'])); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); // Call function $result = $this->SOAPEngine->soapclient->getNumbers($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = $result->total; //print "

";
            //print_r($result);

            print "
            

$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { if (!$result->numbers[$i]) break; $number = $result->numbers[$i]; $index=$this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $j=1; foreach ($number->mappings as $_mapping) { if ($j==1) { printf(" ", $bgcolor, $index, $number->id->number, $number->id->tld, $this->tel2enum($number->id->number,$number->id->tld), ucfirst($_mapping->type), $_mapping->mapto, $_mapping->ttl, $_mapping->priority, $number->owner, $number->info ); } else { printf(" ", $bgcolor, ucfirst($_mapping->type), $_mapping->mapto, $_mapping->ttl, $_mapping->priority ); } $j++; } printf(" "); $i++; } } print "
Id E.164 number Top level domain DNS name Service Map to TTL Priority Owner Info
%s +%s %s %s %s %s %s %s %s %s
%s %s %s %s
"; $this->showPagination($maxrows); return true; } } function showSeachFormCustom() { printf (" E.164 number: ",$this->filters['number']); printf (" TLD: ",$this->filters['tld']); printf (" Service: ",$this->filters['type']); printf (" Map to: ",$this->filters['mapto']); } } class ENUMranges extends Records { var $sortElements=array('changeDate' => 'Change date', 'number' => 'E.164 number', 'tld' => 'TLD', 'owner' => 'Owner' ); function ENUMranges(&$SOAPEngine) { $this->filters = array('number' => trim($_REQUEST['number_filter']), 'tld' => trim($_REQUEST['tld_filter']), 'type' => trim($_REQUEST['type_filter']), 'mapto' => trim($_REQUEST['mapto_filter']), 'owner' => trim($_REQUEST['owner_filter']) ); $this->Records(&$SOAPEngine); } function listRecords() { $this->showSeachForm(); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); // Call function $result = $this->SOAPEngine->soapclient->getRanges(); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = $result->total; //print "

";
            //print_r($result);

            print "
            

$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { if (!$result->numbers[$i]) break; $number = $result->numbers[$i]; $index=$this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $j=1; foreach ($number->mappings as $_mapping) { if ($j==1) { printf(" ", $bgcolor, $index, $number->id->number, $number->id->tld, $this->tel2enum($number->id->number,$number->id->tld), ucfirst($_mapping->type), $_mapping->mapto, $_mapping->ttl, $_mapping->priority, $number->owner, $number->info ); } else { printf(" ", $bgcolor, ucfirst($_mapping->type), $_mapping->mapto, $_mapping->ttl, $_mapping->priority ); } $j++; } printf(" "); $i++; } } print "
Id E.164 prefix Top level domain DNS name TTL Min digits Max digits Used Owner Info
%s +%s %s %s %s %s %s %s %s %s
%s %s %s %s
"; $this->showPagination($maxrows); return true; } } function showSeachFormCustom() { } } class TrustedPeers extends Records { var $sortElements=array( 'description' => 'Description', 'ip' =>'IP address' ); function TrustedPeers(&$SOAPEngine) { $this->filters = array('ip' => trim($_REQUEST['ip_filter']), 'description' => trim($_REQUEST['description_filter']) ); $this->Records(&$SOAPEngine); } function listRecords() { $this->showSeachForm(); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); // Filter $filter=array('ip' => $this->filters['ip'], 'description' => $this->filters['description'] ); // Range $range=array('start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->filters['sortBy']) $this->filters['sortBy'] = 'description'; if (!$this->filters['sortOrder']) $this->filters['sortOrder'] = 'ASC'; $orderBy = array('attribute' => $this->filters['sortBy'], 'direction' => $this->filters['sortOrder'] ); // Compose query $Query=array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->url=sprintf("?sortBy=%s&sortOrder=%s",urlencode($this->filters['sortBy']),urlencode($this->filters['sortOrder'])); if (strlen($this->filters['ip'])) $this->url .= sprintf("&ip_filter=%s",urlencode($this->filters['ip'])); if (strlen($this->filters['description'])) $this->url .= sprintf("&description_filter=%s",urlencode($this->filters['description'])); // Call function $result = $this->SOAPEngine->soapclient->getTrustedPeers($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = $result->total; print "
$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { if (!$result->peers[$i]) break; $peer = $result->peers[$i]; $index=$this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $_url = $_SERVER['PHP_SELF'].sprintf("?service=%s&action=Delete&ip_filter=%s", urlencode($this->SOAPEngine->service), urlencode($peer->ip) ); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['ip_filter'] == $peer->ip) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } printf(" ", $bgcolor, $index, $peer->ip, $peer->protocol, $peer->fromPattern, $peer->description, $peer->owner, $_url, $actionText ); printf(" "); $i++; } } print "
Id IP address Protocol From pattern Description Owner Action
%s %s %s %s %s %s %s
"; $this->showPagination($maxrows); return true; } } function showAddForm() { print "

"; printf ("",$_SERVER['PHP_SELF']); print " "; printf("",$this->SOAPEngine->service); print "
"; print " "; printf (" IP address: "); printf (" Description: "); printf (" Owner: "); print " "; print "
"; } function addRecord() { $ipaddress = trim($_REQUEST['ipaddress']); $description = trim($_REQUEST['description']); $owner = trim($_REQUEST['owner']); if (!strlen($ipaddress) || !strlen($description)) { printf ("

Error: Missing IP or description. "); return false; } $peer=array( 'ip' => $ipaddress, 'description' => $description, 'owner' => intval($_REQUEST['owner']) ); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->addTrustedPeer($peer); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

Trusted peers %s has been added. ",$ipaddress); return 1; } } function deleteRecord() { if (!$_REQUEST['confirm']) { print "

Please press on Confirm to confirm the delete. "; return 1; } if (!strlen($this->filters['ip']) || !strlen($this->filters['ip'])) { print "

Error: missing IP address. "; return 0; } $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->deleteTrustedPeer($this->filters['ip']); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

Trusted peer %s has been deleted. ",$this->filters['ip']); unset($this->filters); return 1; } } } class GatewayGroups extends Records { var $sortElements=array( 'name' => 'Name' ); function GatewayGroups(&$SOAPEngine) { $this->filters = array('group' => trim($_REQUEST['group_filter']) ); $this->Records(&$SOAPEngine); } function listRecords() { $this->showSeachForm(); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); // Filter $filter=array('name' => $this->filters['group'] ); // Range $range=array('start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->filters['sortBy']) $this->filters['sortBy'] = 'name'; if (!$this->filters['sortOrder']) $this->filters['sortOrder'] = 'ASC'; $orderBy = array('attribute' => $this->filters['sortBy'], 'direction' => $this->filters['sortOrder'] ); // Compose query $Query=array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->url=sprintf("?sortBy=%s&sortOrder=%s",urlencode($this->filters['sortBy']),urlencode($this->filters['sortOrder'])); if (strlen($this->filters['group'])) $this->url .= sprintf("&group_filter=%s",urlencode($this->filters['group'])); // Call function $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = $result->total; print "

";
            //print_r($result);
            print "
"; print "
$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { if (!$result->groups[$i]) break; $group = $result->groups[$i]; $index=$this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $_url = $_SERVER['PHP_SELF'].sprintf("?service=%s&action=Delete&group_filter=%s", urlencode($this->SOAPEngine->service), urlencode($group) ); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['group_filter'] == $group) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } printf(" ", $bgcolor, $index, $group, $_url, $actionText ); printf(" "); $i++; } } print "
Id Name Action
%s %s %s
"; $this->showPagination($maxrows); return true; } } function showAddForm() { print "

"; printf ("",$_SERVER['PHP_SELF']); print " "; printf("",$this->SOAPEngine->service); print "
"; print " "; printf (" Name: "); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->getGatewayGroups(); print " "; print "
"; } function addRecord() { $name = trim($_REQUEST['name']); if (!strlen($name)) { printf ("

Error: Missing name. "); return false; } $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->addGatewayGroup($name); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

Gateway group %s has been added. ",$name); return 1; } } function deleteRecord() { if (!$_REQUEST['confirm']) { print "

Please press on Confirm to confirm the delete. "; return 1; } if (!strlen($this->filters['group'])) { print "

Error: missing gateway group. "; return 0; } $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->deleteGatewayGroup($this->filters['group']); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

Gateway %s has been deleted. ",$this->filters['group']); unset($this->filters); return 1; } } function showSeachFormCustom() { printf (" Group: ",$this->filters['group']); } } class Gateways extends Records { var $sortElements=array( 'name' => 'Name', 'group' => 'Group', 'ip' => 'IP address', 'prefix' => 'Prefix' ); function Gateways(&$SOAPEngine) { $this->filters = array('name' => trim($_REQUEST['name_filter']), 'group' => trim($_REQUEST['group_filter']) ); $this->Records(&$SOAPEngine); } function listRecords() { $this->showSeachForm(); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); // Filter $filter=array('name' => $this->filters['name'], 'group' => $this->filters['group'] ); // Range $range=array('start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->filters['sortBy']) $this->filters['sortBy'] = 'name'; if (!$this->filters['sortOrder']) $this->filters['sortOrder'] = 'ASC'; $orderBy = array('attribute' => $this->filters['sortBy'], 'direction' => $this->filters['sortOrder'] ); // Compose query $Query=array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->url=sprintf("?sortBy=%s&sortOrder=%s",urlencode($this->filters['sortBy']),urlencode($this->filters['sortOrder'])); if (strlen($this->filters['name'])) $this->url .= sprintf("&name_filter=%s",urlencode($this->filters['name'])); if (strlen($this->filters['group'])) $this->url .= sprintf("&group_filter=%s",urlencode($this->filters['group'])); // Call function $result = $this->SOAPEngine->soapclient->getGateways($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = $result->total; print "

";
            //print_r($result);
            print "
"; print "
$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { if (!$result->gateways[$i]) break; $gateway = $result->gateways[$i]; $index=$this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $_url = $_SERVER['PHP_SELF'].sprintf("?service=%s&action=Delete&name_filter=%s", urlencode($this->SOAPEngine->service), urlencode($gateway->name) ); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['name_filter'] == $gateway->name) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } printf(" ", $bgcolor, $index, $gateway->name, $gateway->group, $gateway->transport, $gateway->ip, $gateway->port, $gateway->strip, $gateway->prefix, $_url, $actionText ); printf(" "); $i++; } } print "
Id Name Group Address Strip Prefix Action
%s %s %s %s:%s:%s %s %s %s
"; $this->showPagination($maxrows); return true; } } function showAddForm() { print "

"; printf ("",$_SERVER['PHP_SELF']); print " "; printf("",$this->SOAPEngine->service); print "
"; print " "; printf (" Name: "); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->getGatewayGroups(); printf (" Group: "); // Compose query $Query=array('filter' => array('name'=>''), 'orderBy' => array('attribute' => 'name', 'direction' => 'ASC' ), 'range' => array('start' => 0, 'count' => 1000) ); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { print ""); } printf (" Address: "); printf (" Strip: "; printf (" Prefix: "); print "

"; print "
"; } function addRecord() { $name = trim($_REQUEST['name']); $group = trim($_REQUEST['group']); $address = trim($_REQUEST['address']); $strip = trim($_REQUEST['strip']); $prefix = trim($_REQUEST['prefix']); if (!strlen($name) || !strlen($group) || !strlen($address)) { printf ("

Error: Missing name, group or address. "); return false; } $address_els=explode(":",$address); if (count($address_els) == 1) { $ip=$address_els[0]; $transport='udp'; $port='5060'; } else if (count($address_els) == 2) { $ip=$address_els[0]; $port=$address_els[1]; $transport='udp'; } else if (count($address_els) == 3) { $ip=$address_els[1]; $port=intval($address_els[2]); if ($address_els[0] == 'tcp' || $address_els[0] == 'tls' || $address_els[0] == 'udp') { $transport=$address_els[0]; } else { $transport='udp'; } } $gateway=array( 'name' => $name, 'group' => $group, 'ip' => $ip, 'port' => intval($port), 'uriScheme' => 'sip', 'transport' => $transport, 'strip' => intval($_REQUEST['strip']), 'prefix' => $_REQUEST['prefix'] ); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->addGateway($gateway); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

Gateway %s has been added. ",$address); return 1; } } function deleteRecord() { if (!$_REQUEST['confirm']) { print "

Please press on Confirm to confirm the delete. "; return 1; } if (!strlen($this->filters['name'])) { print "

Error: missing gateway name. "; return 0; } $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->deleteGateway($this->filters['name']); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

Gateway %s has been deleted. ",$this->filters['address']); unset($this->filters); return 1; } } function showSeachFormCustom() { printf (" Name: ",$this->filters['name']); printf (" Group: ",$this->filters['group']); } } class Routes extends Records { var $gatewayGroups=array(); var $sortElements=array( 'prefix' => 'Prefix', 'fromURI' => 'From URI', 'priority' => 'Priority' ); function Routes(&$SOAPEngine) { $this->filters = array('prefix' => trim($_REQUEST['prefix_filter']), 'gatewayGroup' => trim($_REQUEST['gatewayGroup_filter']), 'fromURI' => trim($_REQUEST['fromURI_filter']) ); $this->Records(&$SOAPEngine); } function listRecords() { // Get gateway groups $Query=array('filter' => array('name'=>''), 'orderBy' => array('attribute' => 'name', 'direction' => 'ASC' ), 'range' => array('start' => 0, 'count' => 1000) ); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->gatewayGroups=$result->groups; } $this->showSeachForm(); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); // Filter $filter=array('prefix' => $this->filters['prefix'], 'gatewayGroup' => $this->filters['gatewayGroup'], 'fromURI' => $this->filters['fromURI'] ); // Range $range=array('start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->filters['sortBy']) $this->filters['sortBy'] = 'prefix'; if (!$this->filters['sortOrder']) $this->filters['sortOrder'] = 'ASC'; $orderBy = array('attribute' => $this->filters['sortBy'], 'direction' => $this->filters['sortOrder'] ); // Compose query $Query=array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->url=sprintf("?sortBy=%s&sortOrder=%s",urlencode($this->filters['sortBy']),urlencode($this->filters['sortOrder'])); if (strlen($this->filters['prefix'])) $this->url .= sprintf("&prefix_filter=%s",urlencode($this->filters['prefix'])); if (strlen($this->filters['gatewayGroup'])) $this->url .= sprintf("&gatewayGroup_filter=%s",urlencode($this->filters['gatewayGroup'])); if (strlen($this->filters['fromURI'])) $this->url .= sprintf("&fromURI_filter=%s",urlencode($this->filters['fromURI'])); // Call function $result = $this->SOAPEngine->soapclient->getRoutes($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = $result->total; print "

";
            //print_r($result);
            print "
"; print "
$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { if (!$result->routes[$i]) break; $route = $result->routes[$i]; $index=$this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $_url = $_SERVER['PHP_SELF'].sprintf("?service=%s&action=Delete&prefix_filter=%s&gatewayGroup_filter=%s&fromURI_filter=%s&priority_filter=%s", urlencode($this->SOAPEngine->service), urlencode($route->prefix), urlencode($route->gatewayGroup), urlencode($route->fromURI), urlencode($route->priority) ); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['prefix_filter'] == $route->prefix && $_REQUEST['gatewayGroup_filter'] == $route->gatewayGroup && $_REQUEST['fromURI_filter'] == $route->fromURI && $_REQUEST['priority_filter'] == $route->priority) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } printf(" ", $bgcolor, $index, $route->prefix, $route->gatewayGroup, $route->fromURI, $route->priority, $_url, $actionText ); printf(" "); $i++; } } print "
Id Prefix Gateway Group From URI Priority Action
%s %s %s %s %s %s
"; $this->showPagination($maxrows); return true; } } function showAddForm() { print "

"; printf ("",$_SERVER['PHP_SELF']); print " "; printf("",$this->SOAPEngine->service); print "
"; print " "; printf (" Prefix: "); printf (" Group: "); print ""); printf (" From: "); printf (" Priority: "); print " "; print "
"; } function addRecord() { $prefix = trim($_REQUEST['prefix']); $gatewayGroup = trim($_REQUEST['gatewayGroup']); $fromURI = trim($_REQUEST['fromURI']); $priority = trim($_REQUEST['priority']); if (!strlen($prefix) || !strlen($gatewayGroup)) { printf ("

Error: Missing prefix or gatewayGroup. "); return false; } $route=array( 'prefix' => $prefix, 'gatewayGroup' => $gatewayGroup, 'fromURI' => $fromURI, 'priority' => intval($priority) ); $routes=array($route); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->addRoutes($routes); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

Route %s has been added. ",$prefix); return 1; } } function deleteRecord() { if (!$_REQUEST['confirm']) { print "

Please press on Confirm to confirm the delete. "; return 1; } if (!strlen($this->filters['prefix']) || !strlen($this->filters['gatewayGroup'])) { print "

Error: missing route prefix or gatewayGroup. "; return 0; } $route=array( 'prefix' => $this->filters['prefix'], 'gatewayGroup' => $this->filters['gatewayGroup'], 'fromURI' => $this->filters['fromURI'], 'priority' => intval($this->filters['priority']) ); $routes=array($route); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->deleteRoutes($routes); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

Route %s has been deleted. ",$this->filters['prefix']); unset($this->filters); return 1; } } function showSeachFormCustom() { printf (" Prefix: ",$this->filters['prefix']); print ""); printf (" From URI: ",$this->filters['fromURI']); } } class SIPAccounts extends Records { var $sortElements=array('changeDate' =>'Change date', 'username' => 'Username', 'domain' => 'Domain', 'owner' => 'Owner' ); function SIPAccounts(&$SOAPEngine) { global $CDRTool; $this->CDRTool = $CDRTool; $this->filters = array('username' => trim($_REQUEST['username_filter']), 'domain' => trim($_REQUEST['domain_filter']), 'fullname' => trim($_REQUEST['fullname_filter']) ); if ($this->CDRTool['filter']['domain']) { $this->domainsFilter=explode(" ",$this->CDRTool['filter']['domain']); } $this->Records(&$SOAPEngine); } function listRecords() { if (preg_match("/^(.*)@(.*)$/",$this->filters['username'],$m)) { $this->filters['username'] = $m[1]; $this->filters['domain'] = $m[2]; } // Make sure we apply the domain filter from the login credetials if ($this->domainsFilter && !$this->filters['domain']) { $this->filters['domain'] = $this->domainsFilter[0]; } if ($this->filters['domain'] && $this->domainsFilter && !in_array($this->filters['domain'],$this->domainsFilter)) { $this->filters['domain'] = $this->domainsFilter[0]; } $this->showSeachForm(); // Filter $filter=array('username' => $this->filters['username'], 'domain' => $this->filters['domain'], 'name' => $this->filters['fullname'] ); // Range $range=array('start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->filters['sortBy']) $this->filters['sortBy'] = 'changeDate'; if (!$this->filters['sortOrder']) $this->filters['sortOrder'] = 'DESC'; $orderBy = array('attribute' => $this->filters['sortBy'], 'direction' => $this->filters['sortOrder'] ); // Compose query $Query=array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->url=sprintf("?sortBy=%s&sortOrder=%s",urlencode($this->filters['sortBy']),urlencode($this->filters['sortOrder'])); if (strlen($this->filters['username'])) $this->url .= sprintf("&username_filter=%s",urlencode($this->filters['username'])); if (strlen($this->filters['domain'])) $this->url .= sprintf("&domain_filter=%s",urlencode($this->filters['domain'])); if (strlen($this->filters['fullname'])) $this->url .= sprintf("&fullname_filter=%s",urlencode($this->filters['fullname'])); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); // Call function $result = $this->SOAPEngine->soapclient->getAccounts($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = $result->total; print "

$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { if (!$result->accounts[$i]) break; $account = $result->accounts[$i]; $index=$this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $_url = $_SERVER['PHP_SELF'].sprintf("?service=%s&action=Delete&username_filter=%s&domain_filter=%s", urlencode($this->SOAPEngine->service), urlencode($account->id->username), urlencode($account->id->domain) ); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['username_filter'] == $account->id->username && $_REQUEST['domain_filter'] == $account->id->domain) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } $sip_account=sprintf("%s@%s",$account->id->username,$account->id->domain); printf(" ", $bgcolor, $index, $sip_account, $account->timezone, $account->firstName, $account->lastName, $account->email, $account->rpid, $account->changeDate, $_url, $actionText ); $i++; } } print "
Id SIP account Timezone Full name Email Caller Id Change date Action
%s %s %s %s %s %s %s %s %s
"; $this->showPagination($maxrows); return true; } } function showSeachFormCustom() { printf (" Username: ",$this->filters['username']); printf (" Domain: "); if ($this->domainsFilter) { $selected_domain[$this->filters['domain']]='selected'; printf ("",$this->filters['fullname']); } function deleteRecord() { if (!$_REQUEST['confirm']) { print "

Please press on Confirm to confirm the delete. "; return 1; } if (!strlen($this->filters['username']) || !strlen($this->filters['domain'])) { print "

Error: missing SIP account username or domain. "; return 0; } $account=array('username' => $this->filters['username'], 'domain' => $this->filters['domain'] ); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->deleteAccount($account); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

SIP account %s@%s has been deleted. ",$this->filters['username'],$this->filters['domain']); unset($this->filters); return 1; } } function showAddForm() { print "

"; printf ("",$_SERVER['PHP_SELF']); print " "; printf("",$this->SOAPEngine->service); print "
"; print " "; printf (" SIP: ",$_REQUEST['account']); printf (" Pass: ",$_REQUEST['password']); printf (" Name: ",$_REQUEST['fullname']); printf (" Email: ",$_REQUEST['email']); printf (" CallerId: ",$_REQUEST['rpid']); printf (" Owner: ",$_REQUEST['owner']); print " TZ: "; global $CDRTool; if ($_REQUEST['timezone']) { $this->timezone=$_REQUEST['timezone']; } else { $this->timezone=$CDRTool['provider']['timezone']; } $this->showTimezones(); print " "; print "
"; } function addRecord() { $account_els = explode("@", trim($_REQUEST['account'])); $name_els = explode(" ", trim($_REQUEST['fullname'])); $account=array( 'id' => array('username' => $account_els[0], 'domain' => $account_els[1] ), 'firstName' => $name_els[0], 'lastName' => $name_els[1], 'password' => trim($_REQUEST['password']), 'timezone' => trim($_REQUEST['timezone']), 'email' => trim($_REQUEST['email']), 'rpid' => trim($_REQUEST['rpid']), 'owner' => intval($_REQUEST['owner']) ); //print_r($account); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->addAccount($account); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

SIP account %s@%s has been added. ",$alias_els[0],$alias_els[1]); } if (strlen(trim($_REQUEST['rpid']))) { $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->addToGroup(array("username" => $account_els[0],"domain"=> $account_els[1]), "free-pstn"); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("PSTN enabled. "); } } return 1; } } class SIPAliases extends Records { var $sortElements=array( 'aliasUsername' => 'Alias user', 'aliasDomain' => 'Alias domain', 'targetUsername' => 'Target user', 'targetDomain' => 'Target domain', 'owner' => 'Owner' ); function SIPAliases(&$SOAPEngine) { global $CDRTool; $this->CDRTool = $CDRTool; $this->filters = array('aliasUsername' => trim($_REQUEST['alias_username_filter']), 'aliasDomain' => trim($_REQUEST['alias_domain_filter']), 'targetUsername' => trim($_REQUEST['target_username_filter']), 'targetDomain' => trim($_REQUEST['target_domain_filter']) ); if ($this->CDRTool['filter']['domain']) { $this->domainsFilter=explode(" ",$this->CDRTool['filter']['domain']); } $this->Records(&$SOAPEngine); } function listRecords() { // Make sure we apply the domain filter from the login credetials if ($this->domainsFilter && !$this->filters['aliasDomain']) { $this->filters['aliasDomain'] = $this->domainsFilter[0]; } if ($this->filters['aliasDomain'] && $this->domainsFilter && !in_array($this->filters['aliasDomain'],$this->domainsFilter)) { $this->filters['aliasDomain'] = $this->domainsFilter[0]; } $this->showSeachForm(); // Filter $filter=array('aliasUsername' => $this->filters['aliasUsername'], 'aliasDomain' => $this->filters['aliasDomain'], 'targetUsername' => $this->filters['targetUsername'], 'targetDomain' => $this->filters['targetDomain'] ); // Range $range=array('start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->filters['sortBy']) $this->filters['sortBy'] = 'aliasUsername'; if (!$this->filters['sortOrder']) $this->filters['sortOrder'] = 'DESC'; $orderBy = array('attribute' => $this->filters['sortBy'], 'direction' => $this->filters['sortOrder'] ); // Compose query $Query=array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->url=sprintf("?sortBy=%s&sortOrder=%s",urlencode($this->filters['sortBy']),urlencode($this->filters['sortOrder'])); if (strlen($this->filters['aliasUsername'])) $this->url .= sprintf("&alias_username_filter=%s",urlencode($this->filters['aliasUsername'])); if (strlen($this->filters['aliasDomain'])) $this->url .= sprintf("&alias_domain_filter=%s",urlencode($this->filters['aliasDomain'])); if (strlen($this->filters['targetUsername'])) $this->url .= sprintf("&target_username_filter=%s",urlencode($this->filters['targetUsername'])); if (strlen($this->filters['targetDomain'])) $this->url .= sprintf("&target_domain_filter=%s",urlencode($this->filters['targetDomain'])); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); // Call function $result = $this->SOAPEngine->soapclient->getAliases($Query); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = $result->total; //print "

";
            //print_r($result);

            print "
            

$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { if (!$result->aliases[$i]) break; $alias = $result->aliases[$i]; $index=$this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $_url = $_SERVER['PHP_SELF'].sprintf("?service=%s&action=Delete&alias_username_filter=%s&alias_domain_filter=%s", urlencode($this->SOAPEngine->service), urlencode($alias->id->username), urlencode($alias->id->domain) ); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['alias_username_filter'] == $alias->id->username && $_REQUEST['alias_domain_filter'] == $alias->id->domain) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } printf(" ", $bgcolor, $index, $alias->id->username, $alias->id->domain, $alias->target->username, $alias->target->domain, $alias->owner, $_url, $actionText ); $i++; } } print "
Id SIP alias SIP target Owner Action
%s %s@%s %s@%s %s %s
"; $this->showPagination($maxrows); return true; } } function deleteRecord() { if (!$_REQUEST['confirm']) { print "

Please press on Confirm to confirm the delete. "; return 1; } if (!strlen($this->filters['aliasUsername']) || !strlen($this->filters['aliasDomain'])) { print "

Error: missing SIP alias username or domain. "; return 0; } $alias=array('username' => $this->filters['aliasUsername'], 'domain' => $this->filters['aliasDomain'] ); //print_r($alias); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->deleteAlias($alias); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

SIP alias %s@%s has been deleted. ",$this->filters['aliasUsername'],$this->filters['aliasDomain']); unset($this->filters); $this->recordDeleted=1; return 1; } } function showSeachFormCustom() { printf (" User: ",$this->filters['aliasUsername']); printf (" Domain: "); if ($this->domainsFilter) { $selected_domain[$this->filters['aliasDomain']]='selected'; printf ("",$this->filters['targetUsername']); printf (" Target domain: ",$this->filters['targetDomain']); } function showAddForm() { print "

"; printf ("",$_SERVER['PHP_SELF']); print " "; printf("",$this->SOAPEngine->service); print "
"; print " "; printf (" SIP alias: "); printf (" SIP target: "); printf (" Owner: "); print " "; print "
"; } function addRecord() { $alias_els = explode("@", trim($_REQUEST['alias'])); $target_els = explode("@", trim($_REQUEST['target'])); $alias=array( 'id' => array('username' => $alias_els[0], 'domain' => $alias_els[1] ), 'target' => array('username' => $target_els[0], 'domain' => $target_els[1] ), 'owner' => intval($_REQUEST['owner']) ); //print_r($alias); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->addAlias($alias); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

SIP alias %s@%s has been added. ",$alias_els[0],$alias_els[1]); return 1; } } } class DomainStatistics extends Records { var $maxrowsperpage= 200; function DomainStatistics(&$SOAPEngine) { $this->filters = array( 'domain' => trim($_REQUEST['domain_filter']) ); $this->Records(&$SOAPEngine); } function listRecords() { $this->showSeachForm(); // Insert credetials $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $filter=$this->filters['domain']; // Call function $result = $this->SOAPEngine->soapclient->getDomainStatistics($filter); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { $this->rows = count($result); //print_r($result); print "
$this->rows records found

"; if (!$this->next) $this->next=0; if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { $maxrows=$this->rows; } $i=0; if ($this->rows) { while ($i < $this->maxrowsperpage) { $domain = $result[$i]; if (!strlen($domain->users)) break; $index = $this->next+$i+1; $rr=floor($index/2); $mod=$index-$rr*2; if ($mod ==0) { $bgcolor="lightgrey"; } else { $bgcolor="white"; } $_url = $_SERVER['PHP_SELF'].sprintf("?service=%s&action=Delete&domain_filter=%s", urlencode($this->SOAPEngine->service), urlencode($domain->domain) ); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['domain_filter'] == $domain->domain) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } printf(" ", $bgcolor, $index, $domain->domain, $domain->users, $domain->onlineUsers, $domain->onlineDevices, $_url, $actionText ); $i++; } } print "
Id SIP domain SIP subscribers Online subscribers Online SIP devices Action
%s %s %s %s %s %s
"; $this->showPagination($maxrows); return true; } } function showSeachFormCustom() { printf (" Domain: ",$this->filters['domain']); } function deleteRecord() { if (!$_REQUEST['confirm']) { print "

Please press on Confirm to confirm the delete. "; return 1; } if (!strlen($this->filters['domain']) || !strlen($this->filters['domain'])) { print "

Error: missing SIP domain. "; return 0; } $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->deleteDomain($this->filters['domain']); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

SIP domain %s has been deleted. ",$this->filters['domain']); unset($this->filters); return 1; } } function showAddForm() { print "

"; printf ("",$_SERVER['PHP_SELF']); print " "; printf("",$this->SOAPEngine->service); print "
"; print " "; printf (" Domain: "); print " "; print "
"; } function addRecord() { $domain=trim($_REQUEST['domain']); $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); $result = $this->SOAPEngine->soapclient->addDomain($domain); if (PEAR::isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); return false; } else { printf ("

SIP domain %s has been added. ",$domain); return 1; } } } page_close(); ?>